home *** CD-ROM | disk | FTP | other *** search
- Path: ssds.com!usenet
- From: Ron Romero <ron.romero@ssds.com>
- Newsgroups: comp.lang.c++
- Subject: Re: If I were..
- Date: Wed, 20 Mar 1996 16:36:24 -0500
- Organization: SSDS, Inc.
- Distribution: inet
- Message-ID: <31507A58.FAD@ssds.com>
- References: <4ipb8m$541@gerry.cc.keele.ac.uk>
- NNTP-Posting-Host: rem_vie24.ssds.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- JS Willans wrote:
- >
- > [...]
- >
- > I am considering writing the program in pure C++, to get it running on a
- > text based platform, and then porting it to the windows platform using
- > Bordland C++ 4.0. Is this making the task of programming for Visual C++
- > more difficult, or is this a wise approach?
- > In general, writing a program to work with multiple interfaces is a good idea.
- By writing your program first for a text based platform, then for MS Windows,
- you are forcing yourself to split the user interface of your program from the
- underlying implementation. Making this seperation keeps the internals of your
- program from reflecting the peculiarities of the user interface. Thus your
- program is more robust, can be adapted for multiple platforms, and can have
- cleaner code.
-
- There are a couple of techniques for managing the user interface/ internal
- implementation split. You can physically divide the source code into two
- directories. This makes the split very obvious and definite. And, when you add
- new interfaces, you simply add new interface directories.
-
- Also, you should try to keep the first (text based) interface working when you
- port the program to MS Windows. Do not hack the internal code just to get the
- user interface to work. If you do find you need to change something, either
- change the text interface as well, or, better yet, make the change incremental.
- That is, change the internals in such a way that the old code still works.
-
- This is an example of a common pattern in programming, called Model/View.
- (Technically "Model/View/Controller," but most people don't use Controllers")
- The Model is the "internal" code; it is not interface specific. Your model is
- written in pure C++, without platform extensions. The View is the user
- interface. It provides a "view" of the model. The view knows about the model,
- but the model has absolutely no knowledge of the view. Thus, you can change out
- views without the model's knowledge, in your example, switching from text to
- windows.
-
- > Regards
- >
- > James
- >
- > ______________________________________________________________________________
- > James Willans Music and Computing Student
- > University of Keele email u5b34@cs.keele.ac.uk
- > Keele u5b34@cc.keele.ac.uk
- > Staffordshire
-
- Ron Romero
- ron.romero@ssds.com
- SSDS, Inc.
- (signature under construction)
-